<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: EasySvg   SvgConfigParser.js </title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css?stamp=1332454810.31" />
	<link rel="stylesheet" type="text/css" href="assets/api.css?stamp=1332454810.31" />

    <script type="text/javascript" src="assets/api-js?stamp=1332454810.31"></script>
    <script type="text/javascript" src="assets/ac-js?stamp=1332454810.31"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1>EasySvg</h1>
        <h3>EasySvg&nbsp; <span class="subtitle">1.0.0</span></h3>
        <a href="./index.html">EasySvg</a>
            &gt; <a href="./module_easysvg.html" title="EasySvg">EasySvg</a>
                
                 &gt; SvgConfigParser.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
<div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * Class for parsing json and generate SvgContainer and SvgElement objects</span>
<span class="cm"> * @class SvgConfigParser</span>
<span class="cm"> * @extends Class</span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @param {object} config  See configuration attributes</span>
<span class="cm"> * @param {SVGElement} Dom svg element of the parent container</span>
<span class="cm"> * @param {SvgCanvas} The svg stage/canvas</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * The svg element type</span>
<span class="cm"> * @config type </span>
<span class="cm"> * @type String</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An array of config objects which represents the child elements</span>
<span class="cm"> * @config items </span>
<span class="cm"> * @type Array</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An config object with attributes of the svg element</span>
<span class="cm"> * @config attr </span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An config object with event listeners for the svg element</span>
<span class="cm"> * @config listeners </span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An config object which represents a child animation element</span>
<span class="cm"> * @config animate </span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An config object which represents a child animationTransform element</span>
<span class="cm"> * @config animateTransform </span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="cm">/**</span>
<span class="cm"> * An config object which represents a child animationMotion element</span>
<span class="cm"> * @config animateMotion </span>
<span class="cm"> * @type Object</span>
<span class="cm"> */</span>
<span class="kd">var</span> <span class="nx">SvgConfigParser</span> <span class="o">=</span> <span class="p">{</span>
    <span class="nx">svg</span><span class="o">:</span> <span class="kc">null</span><span class="p">,</span>
    
    <span class="cm">/**</span>
<span class="cm">     * @private</span>
<span class="cm">     * @method init</span>
<span class="cm">     * @memberOf SvgConfigParser</span>
<span class="cm">     */</span>
    <span class="nx">init</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">config</span><span class="p">,</span> <span class="nx">container</span><span class="p">,</span> <span class="nx">canvas</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">svg</span> <span class="o">=</span> <span class="nx">canvas</span><span class="p">,</span> 
            <span class="nx">parse</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">c</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">o</span> <span class="o">&amp;&amp;</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span><span class="o">==</span><span class="s2">&quot;object&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">isContainer</span> <span class="o">=</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">items</span> <span class="o">&amp;&amp;</span> <span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">items</span><span class="p">));</span>
                    <span class="kd">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">isContainer</span> <span class="o">?</span> <span class="k">new</span> <span class="nx">SvgContainer</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">,</span> <span class="nx">c</span><span class="p">,</span> <span class="nx">svg</span><span class="p">)</span> <span class="o">:</span> <span class="k">new</span> <span class="nx">SvgElement</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">,</span> <span class="nx">c</span><span class="p">,</span> <span class="nx">svg</span><span class="p">);</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">attr</span><span class="p">)</span> <span class="nx">el</span><span class="p">.</span><span class="nx">attr</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">attr</span><span class="p">);</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">isContainer</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">o</span><span class="p">.</span><span class="nx">items</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="nx">parse</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="nx">el</span><span class="p">.</span><span class="nx">dom</span><span class="p">);</span>
                    <span class="p">}</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">listeners</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">l</span> <span class="k">in</span> <span class="nx">o</span><span class="p">.</span><span class="nx">listeners</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">el</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="nx">l</span><span class="p">,</span> <span class="nx">o</span><span class="p">.</span><span class="nx">listeners</span><span class="p">[</span><span class="nx">l</span><span class="p">],</span> <span class="nx">el</span><span class="p">);</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">))</span> <span class="p">{</span>
                            <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="nx">el</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        <span class="p">}</span> <span class="k">else</span>
                            <span class="nx">el</span><span class="p">.</span><span class="nx">animate</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">.</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animate</span><span class="p">.</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        
                    <span class="p">}</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">))</span> <span class="p">{</span>
                            <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="nx">el</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        <span class="p">}</span> <span class="k">else</span>
                            <span class="nx">el</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">.</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animateTransform</span><span class="p">.</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        
                    <span class="p">}</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">))</span> <span class="p">{</span>
                            <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="nx">el</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        <span class="p">}</span> <span class="k">else</span>
                            <span class="nx">el</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">.</span><span class="nx">attr</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">animateMotion</span><span class="p">.</span><span class="nx">attr</span> <span class="o">:</span> <span class="p">{});</span>
                        
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">};</span>
        
        <span class="k">this</span><span class="p">.</span><span class="nx">svg</span><span class="o">=</span><span class="nx">canvas</span><span class="p">;</span>
        <span class="nx">parse</span><span class="p">(</span><span class="nx">config</span><span class="p">,</span> <span class="nx">container</span><span class="p">);</span>
    <span class="p">}</span>   
    
<span class="p">};</span>
<span class="nx">SvgConfigParser</span> <span class="o">=</span> <span class="nx">Class</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">SvgConfigParser</span><span class="p">);</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class="selected"><a href="module_EasySvg.html" title="EasySvg">EasySvg</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="Class.html" title="Class">Class</a></li>
                                <li class=""><a href="EasySvg.html" title="EasySvg">EasySvg</a></li>
                                <li class=""><a href="SvgCanvas.html" title="SvgCanvas">SvgCanvas</a></li>
                                <li class=""><a href="SvgConfigParser.html" title="SvgConfigParser">SvgConfigParser</a></li>
                                <li class=""><a href="SvgContainer.html" title="SvgContainer">SvgContainer</a></li>
                                <li class=""><a href="SvgDefines.html" title="SvgDefines">SvgDefines</a></li>
                                <li class=""><a href="SvgDefsParser.html" title="SvgDefsParser">SvgDefsParser</a></li>
                                <li class=""><a href="SvgElement.html" title="SvgElement">SvgElement</a></li>
                                <li class=""><a href="SvgGradient.html" title="SvgGradient">SvgGradient</a></li>
                                <li class=""><a href="SvgImage.html" title="SvgImage">SvgImage</a></li>
                                <li class=""><a href="SvgLinearGradient.html" title="SvgLinearGradient">SvgLinearGradient</a></li>
                                <li class=""><a href="SvgRadialGradient.html" title="SvgRadialGradient">SvgRadialGradient</a></li>
                                <li class=""><a href="SvgText.html" title="SvgText">SvgText</a></li>
                                <li class=""><a href="SvgUse.html" title="SvgUse">SvgUse</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="Class.js.html" title="Class.js">Class.js</a></li>
                                <li class=""><a href="EasySvg.js.html" title="EasySvg.js">EasySvg.js</a></li>
                                <li class=""><a href="SvgCanvas.js.html" title="SvgCanvas.js">SvgCanvas.js</a></li>
                                <li class="selected"><a href="SvgConfigParser.js.html" title="SvgConfigParser.js">SvgConfigParser.js</a></li>
                                <li class=""><a href="SvgContainer.js.html" title="SvgContainer.js">SvgContainer.js</a></li>
                                <li class=""><a href="SvgDefines.js.html" title="SvgDefines.js">SvgDefines.js</a></li>
                                <li class=""><a href="SvgDefsParser.js.html" title="SvgDefsParser.js">SvgDefsParser.js</a></li>
                                <li class=""><a href="SvgElement.js.html" title="SvgElement.js">SvgElement.js</a></li>
                                <li class=""><a href="SvgGradient.js.html" title="SvgGradient.js">SvgGradient.js</a></li>
                                <li class=""><a href="SvgImage.js.html" title="SvgImage.js">SvgImage.js</a></li>
                                <li class=""><a href="SvgLinearGradient.js.html" title="SvgLinearGradient.js">SvgLinearGradient.js</a></li>
                                <li class=""><a href="SvgRadialGradient.js.html" title="SvgRadialGradient.js">SvgRadialGradient.js</a></li>
                                <li class=""><a href="SvgText.js.html" title="SvgText.js">SvgText.js</a></li>
                                <li class=""><a href="SvgUse.js.html" title="SvgUse.js">SvgUse.js</a></li>
                                <li class=""><a href="utils.js.html" title="utils.js">utils.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2012 Helge Andersen. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"url": "SvgContainer.html#method_add", "access": "", "host": "SvgContainer", "type": "method", "name": "add"}, {"url": "SvgConfigParser.html#config_animate", "access": "", "host": "SvgConfigParser", "type": "config", "name": "animate"}, {"url": "SvgConfigParser.html#config_animateMotion", "access": "", "host": "SvgConfigParser", "type": "config", "name": "animateMotion"}, {"url": "SvgConfigParser.html#config_animateTransform", "access": "", "host": "SvgConfigParser", "type": "config", "name": "animateTransform"}, {"url": "SvgCanvas.html#config_attr", "access": "", "host": "SvgCanvas", "type": "config", "name": "attr"}, {"url": "SvgConfigParser.html#config_attr", "access": "", "host": "SvgConfigParser", "type": "config", "name": "attr"}, {"url": "SvgElement.html#method_attr", "access": "", "host": "SvgElement", "type": "method", "name": "attr"}, {"url": "SvgContainer.html#method_circle", "access": "", "host": "SvgContainer", "type": "method", "name": "circle"}, {"url": "SvgContainer.html#method_clear", "access": "", "host": "SvgContainer", "type": "method", "name": "clear"}, {"url": "SvgCanvas.html#method_defines", "access": "", "host": "SvgCanvas", "type": "method", "name": "defines"}, {"url": "SvgCanvas.html#config_el", "access": "", "host": "SvgCanvas", "type": "config", "name": "el"}, {"url": "SvgContainer.html#method_ellipse", "access": "", "host": "SvgContainer", "type": "method", "name": "ellipse"}, {"url": "SvgContainer.html#method_group", "access": "", "host": "SvgContainer", "type": "method", "name": "group"}, {"url": "SvgContainer.html#method_image", "access": "", "host": "SvgContainer", "type": "method", "name": "image"}, {"url": "EasySvg.html#method_isSupported", "access": "", "host": "EasySvg", "type": "method", "name": "isSupported"}, {"url": "SvgConfigParser.html#config_items", "access": "", "host": "SvgConfigParser", "type": "config", "name": "items"}, {"url": "SvgDefsParser.html#config_items", "access": "", "host": "SvgDefsParser", "type": "config", "name": "items"}, {"url": "SvgContainer.html#method_line", "access": "", "host": "SvgContainer", "type": "method", "name": "line"}, {"url": "SvgDefines.html#method_linearGradient", "access": "", "host": "SvgDefines", "type": "method", "name": "linearGradient"}, {"url": "SvgConfigParser.html#config_listeners", "access": "", "host": "SvgConfigParser", "type": "config", "name": "listeners"}, {"url": "SvgElement.html#method_on", "access": "", "host": "SvgElement", "type": "method", "name": "on"}, {"url": "SvgContainer.html#method_polygon", "access": "", "host": "SvgContainer", "type": "method", "name": "polygon"}, {"url": "SvgContainer.html#method_polyline", "access": "", "host": "SvgContainer", "type": "method", "name": "polyline"}, {"url": "SvgDefines.html#method_radialGradient", "access": "", "host": "SvgDefines", "type": "method", "name": "radialGradient"}, {"url": "SvgContainer.html#method_rect", "access": "", "host": "SvgContainer", "type": "method", "name": "rect"}, {"url": "SvgGradient.html#method_stop", "access": "", "host": "SvgGradient", "type": "method", "name": "stop"}, {"url": "EasySvg.html#method_svg", "access": "", "host": "EasySvg", "type": "method", "name": "svg"}, {"url": "SvgDefines.html#method_symbol", "access": "", "host": "SvgDefines", "type": "method", "name": "symbol"}, {"url": "SvgContainer.html#method_text", "access": "", "host": "SvgContainer", "type": "method", "name": "text"}, {"url": "SvgImage.html#method_title", "access": "", "host": "SvgImage", "type": "method", "name": "title"}, {"url": "SvgText.html#method_tspan", "access": "", "host": "SvgText", "type": "method", "name": "tspan"}, {"url": "SvgConfigParser.html#config_type", "access": "", "host": "SvgConfigParser", "type": "config", "name": "type"}, {"url": "SvgContainer.html#method_use", "access": "", "host": "SvgContainer", "type": "method", "name": "use"}];
</script>
</body>
</html>
